<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 14-10-20
 * Time: 下午12:58
 * @author 郑钟良<zzl@ourstu.com>
 */

namespace Question\Widget;

use Think\Action;

class AnswerWidget extends Action
{
    public function answer($question_id=0,$limit=0)
    {
        $answerList=D('Question/QuestionAnswer')->getAnswerList(array('question_id'=>$question_id),$limit,$totalCount,'create_time desc');
        $this->assign('answerList',$answerList);
        $this->assign('question_id',$question_id);
        if($limit!=0){
            if($totalCount>$limit){
                $moreCount=$totalCount-$limit;
            }
        }
        $this->assign('moreCount',$moreCount?$moreCount:0);
        $this->display(T('Question@Widget/answer'));
    }

    public function response($answer_id=0,$limit=0){
        $responseList=D('Question/QuestionAnswer')->getResponseList($answer_id,$totalCount,$limit,'create_time asc');
        $this->assign('responseList',$responseList);
        $this->assign('answer_id',$answer_id);
        if($limit!=0){
            if($totalCount>$limit){
                $moreCount=$totalCount-$limit;
            }
        }
        $this->assign('moreCount',$moreCount?$moreCount:0);
        $this->display(T('Question@Widget/response'));
    }

    public function answerbox($answer_id=0){
        $question['id']=$answer_id;
        $this->assign('question',$question);
        $this->assign('is_only_answer',1);
        $this->display(T('Question@Public/_answerbox'));
    }
} 